//axios
//
import axios from 'axios';
//导入
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';// 
import { toast } from "react-toastify";

//创建实例对象
let instance = axios.create({
    baseURL: 'http://xiaohigh.picp.vip/'
});

//拦截器
instance.interceptors.request.use((config) => {
    //显示进度条
    NProgress.start();
    return config;
}, (error) => {
    return Promise.reject(error); 
});

instance.interceptors.response.use((response) => {
    //隐藏进度条
    NProgress.done();
    return response.data;
}, (error) => {
    toast.error("xxx请求异常, 请稍后再试~~", {
        position: toast.POSITION.TOP_RIGHT,
    });
    return new Promise(() => {})
});

//暴露对象
export default instance;